import java.net.*;
import java.io.*;

public class SMS {

	public static void sendSMS(String phone, String carrier) {
		try {
			
			// finds the carrier from the drop down menu
			if (carrier == "AT&T")
				carrier = "A";
			else if (carrier == "Verizon")
				carrier = "V";
			else if (carrier == "T-Mobile")
				carrier = "T";
			else if (carrier == "Sprint / Nextel")
				carrier = "S";

			// uses a host to send the SMS text through email
			URL url = new URL("http://www.plasmahosting.net/gui/sms.php?phone="
					+ phone + "&carrier=" + carrier);
			URLConnection connection = url.openConnection();
			connection.setDoInput(true);
			InputStream inStream = connection.getInputStream();
			BufferedReader input = new BufferedReader(new InputStreamReader(
					inStream));

			String line = "";
			while ((line = input.readLine()) != null) {
				if (line.equals("Success")) {
					System.out.println("SMS Sent Successfully.");
					System.out.println(input.readLine());
				} else if (line.equals("Invalid")) {
					System.out.println("Invalid Phone Number.");
					System.out.println(input.readLine());
				} else {
					System.out.println("SMS Sending Failure.");
					System.out.println("line");
				}
				break;
			}
		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}